Public Class FormUserRequest
    Dim usercode, username, userphone As String
    Dim tooltip As ToolTip
    Dim rndnumber As Random
    Dim number As Integer

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Try
            randomPasswords()
            ''========================
            'If txtUserCode.Text = "" Then
            '    tooltip.IsBalloon = True
            '    Me.Highlighter1.SetHighlightColor(Me.txtUserCode, DevComponents.DotNetBar.Validator.eHighlightColor.Red)
            '    tooltip.InitialDelay = 10
            '    tooltip.ToolTipTitle = "Warning"
            '    tooltip.ToolTipIcon = ToolTipIcon.Warning
            '    tooltip.SetToolTip(txtUserCode, "Please input correct employee code.")
            '    txtUserCode.SelectAll()
            '    txtUserCode.Focus()

            '    Exit Sub
            'Else
            '    Me.Highlighter1.SetHighlightColor(Me.txtUserCode, DevComponents.DotNetBar.Validator.eHighlightColor.None)
            'End If
            ''''''''''''''''''''''''''''
            Dim LogOutAfter = Cmd.ExecuteDataTable("SELECT * FROM TBL_EMPLOYEE WHERE EMP_CODE ='" & txtUserCode.Text & "' AND EMP_NAME='" & txtUserName.Text & "' AND PHONE ='" & txtUserphone.Text & "' AND ACTIVE=1")
            If (LogOutAfter.Rows.Count = 1) Then

                Me.usercode = LogOutAfter.Rows(0)("EMP_CODE")
                Me.username = LogOutAfter.Rows(0)("EMP_NAME")
                Me.userphone = LogOutAfter.Rows(0)("EMP_NAME")
                Lbl_PassInfor.Text = "Successful to change your password. This is your new password     " + number.ToString
                Cmd.ExecuteNonquery("INSERT INTO TBL_USER_REQUEST (REQUEST_CODE,REQUEST_NAME,PHONE,DESCRIPTION,REQUEST_DATE,ACTIVE) VALUES('" & txtUserCode.Text & "','" & txtUserName.Text & "','" & txtUserphone.Text & "','" & txtDescription.Text & "','" & DateTimePicker1.Text & "',1)")

                Cmd.ExecuteNonquery("UPDATE SYS_USER SET PASSWORD='" & number & "' WHERE USER_CODE ='" & txtUserCode.Text & "'")


                txtUserCode.Clear()
                txtUserName.Clear()
                txtDescription.Clear()
                txtUserphone.Clear()
                DateTimePicker1.Text = Now

                Exit Sub
            Else
                FormMessage.LBL_Message.Text = "Your Request is unsuccessful !"
                FormMessage.Size = New System.Drawing.Size(369, 129)
                FormMessage.ShowDialog()

            End If

        Catch ex As Exception

        End Try
    End Sub

    Public Sub randomPasswords()

        rndnumber = New Random

        number = rndnumber.Next(10000000, 80000000)

    End Sub

    Private Sub FormUserRequest_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
        If Lbl_PassInfor.Text = "" Then
            Me.Close()
        Else
            FormLogin.Txtpassword.Text = number
        End If

    End Sub

    Private Sub FormUserRequest_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class